import com.speljohan.rsbot.script.Random;

public class RewardsBox extends Random {

	int Box_Id = 14664;
	int INTERFACE_RANDOMBOX = 202;

	@Override
	public boolean activateCondition() {
		return inventoryContains(Box_Id);
	}

	@Override
	public String getAuthor() {
		return "Pwnaz0r";
	}

	@Override
	public String getName() {
		return "Rewards Box";
	}

	@Override
	public double getVersion() {
		return 1;
	}

	@Override
	public int loop() {
		if (!inventoryContains(Box_Id)) {
			return -1;
		}

		if (getInterface(INTERFACE_RANDOMBOX).isValid()) {
			if (getInterface(INTERFACE_RANDOMBOX, 28).getText().contains(
					"onfirm")) {
				atInterface(INTERFACE_RANDOMBOX, 28);
				return random(400, 900);
			} else {
				clickMouse(random(47, 186), random(80, 134), true);
				return random(700, 1200);
			}
		} else {
			atInventoryItem(Box_Id, "Open");
			return random(3000, 5000);
		}
	}
}